<?php
	defined( '_JEXEC' ) or die( 'Restricted access' );	#step 3	$page_heading = JTEXT::_('WRD_PROFILE_PROFILE');	$title = JText::_('WMCVIP_TITLE_PREFIX').$page_heading.JText::_('WMCVIP_TITLE_SUFIX');	$document = &JFactory::getDocument();	$document->setTitle($title) ;
?>
<link href="<?php echo JURI::base(true)?>/administrator/components/com_wrd/assets/css/jquery.autocomplete.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="<?php echo JURI::base(true)?>/administrator/components/com_wrd/assets/js/jquery-migrate-1.1.1.min.js"></script>
<script type="text/javascript" src="<?php echo JURI::base(true)?>/administrator/components/com_wrd/assets/js/jquery.autocomplete.js"></script>
<script type="text/javascript">
	jQuery(document).ready(function()
	{
		jQuery("#company_name").autocomplete("<?php echo JRoute::_("index.php?option=com_wrd&task=getCompanies", false)?>", {
		    width: 260,
		    matchContains: true,
		    minChars: 1,
		    selectFirst: false
		});
	});
var sectioncountrys = new Array();	
<?php		
foreach ($this->lists['countryToCity'] as $k=>$item)
 {			
	echo "sectioncountrys[".$k."] = new Array( '$item->country_id','".addslashes( $item->id )."','".addslashes( $item->name )."' );\n\t\t";		
 }	
 ?>	var sectioncitys = new Array();	
 <?php		
 foreach ($this->lists['cityToDistric'] as $k=>$item) {			
 echo "sectioncitys[".$k."] = new Array( '$item->city_id','".addslashes( $item->id )."','".addslashes( $item->name )."' );\n\t\t";		
 }	?>	
 
 function changeCity( listname, source, key, orig_key, orig_val) {
 	var list = eval( 'document.default_registration_form.' + listname );		
 	// empty the list		
 	for (i in list.options.length) 
 	{
 		list.options[i] = null;		
 	}		
	 var i = 0;		
	 var j = 0;		
	 for (x in source) {			
 		if (source[x][0] == key) {	
 			opt = new Option();				
 			opt.value = source[x][1];				
 			opt.text = source[x][2];				
 			if ((orig_key == key && orig_val == opt.value) || i == 0) {					
 				opt.selected = true;					
 				j = opt.value;				
 			}				
 			list.options[i++] = opt;			
 			}		
 	}		
 	if(i == 0){			
 		opt = new Option();			
 		opt.value = 0;			
 		opt.text = '<?php echo JText::_('WRD_OPT_SELECT_CITY') ?>';			
 		opt.selected = true;			
 		list.options[i++] = opt;		
 	}		
 	list.length = i;		
 	if(listname == 'c_city'){			
 		changeDistric('c_distric' ,sectioncitys,j,0,0);		
 	}
 	}	
 	
 	function changeDistric( listname , source, key, orig_key, orig_val){		
 		var list = eval( 'document.default_registration_form.' + listname );		
 		for (i in list.options.length) {			
 			list.options[i] = null;		
 		}

 		var i = 0;		
 		for (x in source) {			
 			if (source[x][0] == key) {				
 				opt = new Option();				
 				opt.value = source[x][1];				
 				opt.text = source[x][2];				
 				if ((orig_key == key && orig_val == opt.value) || i == 0) {					
 					opt.selected = true;				
 				}				
 				list.options[i++] = opt;			
 				
 				}		
 			}		
 			
 			if(i == 0){			
 				opt = new Option();			
 				opt.value = 0;			
 				opt.text = '<?php echo JText::_('WRD_OPT_SELECT_DISTRICT') ?>';			
 				opt.selected = true;			
 				list.options[i++] = opt;		
 			}		
 		
 		list.length = i;	
 		}
 		
 		function showOther(ex,id){		
 			vl = document.getElementById(ex).value;		
 			if(vl=="other"){			
 				document.getElementById(id).style.display = '';			
 				
 			}else{			
 				document.getElementById(id).style.display = 'none';		
 			}	
 		}
 </script>
<h1 class="all_reward_header"><?php echo $page_heading; ?></h1><div class="panel  panel-wmc">  <div class="panel-heading">    <h3 class="panel-title"><?php echo JText::_('WRD_PROFILE_ACCOUNT_PREFERENCE')?></h3>  </div>  <div class="panel-body">    <p><strong style="color:#3E3061;"><?php echo $this->data->name_on_card; ?></strong></p>    <p><?php echo JText::_('WRD_PROFILE_BALANCE')?>: <span class='link_color'>		<?php echo number_format($this->p_o_u->point,0,'.',',') ;?>		<?php echo JText::_('WRD_PROFILE_POINTS')?> </span></p>	<p><a href="<?php echo JRoute::_('index.php?option=com_wrd&view=profile&layout=myaccount&Itemid=119') ?>">		<?php echo JText::_('WRD_PROFILE_VIEW_THE_SUMMARY_OF_YOUR_POINTS')?></a></p>  </div></div><?php if($this->data->total_step != 4): ?><div class="alert alert-info">	<?php echo JText::_('WRD_HEADER_MESSAGE_STEP3'); ?></div><?php endif; ?><div class="progress" style="display: none">    <?php 	    	if($this->data->user_id != 0)    	{    		$step = $this->data->total_step+1;			    		if($step > 1):                $pointstep = WrdHelper::totalPointOfEachStep($step);            endif;    		switch ($step){    			case 1:    			?>				<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100" style="width: 20%">    				<?php echo JText::_('WRD_PROFILE_PLEASE_FILL_ALL_FILEDS_OF_THIS_STEP')?>				</div>    			<?php    			break;    			case 2:    			?>          		                <div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width: 40%">    				<?php echo JText::_('WRD_PROFILE_POINT_REWARDS_IS_COMMING_TO_YOUR_ACCOUNT_BY_THIS_STEP')?>				</div>    			<?php    				break;    			case 3:    			?>				<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 60%">    				<?php echo JText::_('WRD_PROFILE_POINTS_REWARDS')?>				</div>    			<?php    				break;    			case 4:    			?>				<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="80" aria-valuemin="0" aria-valuemax="100" style="width: 80%">    				<?php echo JText::_('WRD_PROFILE_POINTS_AND_FINISH')?>				</div>    			<?php    				break;    			case 5:    			?>                <div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%">    				<?php echo JText::_('WRD_PROFILE_POINTS_AND_FINISH')?>				</div>    			<?php    				break;    		}    	}    ?></div>  <ul class="nav nav-tabs nav-wmc nav-justified">  <li><a href="<?php echo JRoute::_('index.php?option=com_wrd&view=profile&layout=default&id=1&Itemid=170') ?>"><?php echo JText::_('WRD_PROFILE_BASIC_INFOMATION') ?></a></li>  <li><a href="#">  		<?php echo JText::_('WRD_PROFILE_PERSONAL_INFOMATION') ?></a></li>  <li class="active"><a href="<?php echo JRoute::_('index.php?option=com_wrd&view=profile&layout=default&id=2&Itemid=170') ?>">  	<?php echo JText::_('WRD_PROFILE_BIZ_CONTACT') ?></a>  </li>  <li><a href="<?php echo JRoute::_('index.php?option=com_wrd&view=profile&layout=default&id=4&Itemid=170') ?>">  	<?php echo JText::_('WRD_PROFILE_PROFESSIONALISM') ?></a>  </li></ul>    
 <div id="profile" class="twelve columns">
     <form role="form"      	onsubmit="return checkForm(this);" id="profile-registration"      	name="default_registration_form" class="form-validate" method="post"      	action="<?php echo JRoute::_('index.php?option=com_wrd&task=profile.save'); ?>">	     			<p class="help-block pull-right"><?php echo JText::_('WRD_PROFILE_THE_FILEDS') ?><b style="color: #FF0000 ; padding: 0px 5px ;">*</b> <?php echo JText::_('WRD_PROFILE_ARE') ?> <b style="color: #FF0000 ; padding: 0px 5px ;"><?php echo JText::_('WRD_PROFILE_REQUIRED') ?></b>.</p>		<br clear="all">		<div class="form-group">				            <label for="title">            	<?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP3_'.$this->configField['job']['caption'])); ?>            	<b style="color: #FF0000 ; padding: 0px 5px ;">*</b>            </label>			         			             <div class='f-left'>             	<?php echo $this->lists['job_prefix']; ?></div>				<br>             <div id="fl_job_prefix" class='f-left' <?php if($this->data->job_prefix != 'other'){ echo "style='display:none'" ; } ?> >                             	<input type="text" maxlength="49" size="49"               		value="<?php echo $this->data->o_job_prefix; ?>"              		id="o_job_prefix" name="o_job_prefix"              		title="<?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP3_OTHER_JOB_PREFIX_TIP')); ?>"              		class="has-tip tip-right noradius form-control" />             </div>			<br>             <?php echo $this->lists['job']; ?>             <br>             <div id="fl_o_job" class='f-left' <?php if($this->data->job != 'other'){ echo "style='display:none'" ; } ?> >                             	<input type="text" maxlength="49" size="49"             		value="<?php echo $this->data->o_job; ?>"              		id="o_job" name="o_job"              		title="<?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP3_Other')); ?>"              		class="has-tip tip-right noradius form-control" />             </div>			         </div>		<div class="form-group">				            <label for="title">            	<?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP3_'.$this->configField['department']['caption'])); ?>            </label>			            <?php echo $this->lists['department']; ?>				        </div>			    <div class="form-group" id="fl_o_department" <?php if($this->data->department != 'other'){echo "style='display:none'" ; }?>>				       		<label for="title"><?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP3_Other')); ?></label>		            <div class="other">										<input type="text" maxlength="50" size="50" value="<?php echo $this->data->o_department ; ?>" id="o_department" name="o_department" title="<?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP3_Other_DEPARTMENT_TIP')); ?>" class="has-tip tip-right noradius form-control" />						            </div>					        </td>				    </div>		<div class="form-group">		            <label for="title">            	<?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP3_'.$this->configField['company_name']['caption'])); ?>            	<b style="color: #FF0000 ; padding: 0px 5px ;">*</b>            </label>			            <input type="text" maxlength="54" size="54" value="<?php echo $this->data->company_name; ?>"             id="company_name" name="company_name"             title="<?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP3_company_name_TIP')); ?>"             class="five has-tip tip-right noradius form-control" />				        </div>			<div class="form-group">            <label for="title"><?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP3_'.$this->configField['industry']['caption'])); ?></label>			            <?php echo $this->lists['industry']; ?>				        </div>		<div class="form-group" id="fl_o_industry" <?php if($this->data->industry != 'other'){echo "style='display:none'" ; }?>>				        <div class="other">									<label for="title"><?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP3_INDUSTRY_Other')); ?></label>										<input type="text" maxlength="50" size="50" value="<?php echo $this->data->o_industry ; ?>" id="o_industry" name="o_industry" title="<?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP3_Other_INDUSTRY_TIP')); ?>" class="has-tip tip-right noradius" />								</div>    	</div>			<div class="form-group">			<label for="title"><?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP3_'.$this->configField['c_info']['caption'])); ?></label>						<input type="text" maxlength="54" size="54" 			value="<?php echo $this->data->c_info; ?>" id="c_info" name="c_info" 			title="<?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP3_c_info_TIP')); ?>" 			class="five has-tip tip-right noradius form-control" />				    	</div>		<div class="form-group">						<label for="title"><?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP3_'.$this->configField['c_addr']['caption'])); ?></label>				        <input type="text" maxlength="54" size="54" value="<?php echo $this->data->c_addr; ?>" id="c_addr" name="c_addr" 	        title="<?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP3_c_addr_TIP')); ?>" 	        class="five has-tip tip-right noradius form-control" />				    	</div>		<div class="form-group">							<label for="title">				<?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP3_'.$this->configField['c_country']['caption'])); ?>			</label>						<?php echo $this->lists['country']; ?>					    </div>		<div class="form-group">						<label for="title"><?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP3_'.$this->configField['c_city']['caption'])); ?></label>						<?php echo $this->lists['city']; ?>				    	</div>			<div class="form-group">						<label for="title">				<?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP3_'.$this->configField['c_distric']['caption'])); ?></label>						<?php echo $this->lists['distric']; ?>					   </div>	   		<div class="form-group pull-right">    	<input type="submit" value="<?php echo JText::_('WRD_PROFILE_SAVE_CONTINUE') ?>" onclick="document.getElementById('continue').value = 1" id="save_and_continue" name="save_and_continue" class="button_save_and_continue bt btn btn-wmc" />					</div>	<br clear="all">
	<input type="hidden" id="continue" name="continue" value="">	
	<input type="hidden" name="profile" value="<?php echo $this->data->id ?>">	
	<input type="hidden" name="option" value="com_wrd">
	<input type="hidden" name="task" value="profile.save">	
	<?php echo JHtml::_('form.token');?></form>
</div>

<script type="text/javascript">
	function checkForm(frm){
		if(frm.job_prefix.value == -1){			
			frm.job_prefix.focus();			jQuery('#error_message').html('<p><?php echo JText::_('WRD_PROFILE_ALERT_PLEASE_SELECT_JOB_PREFIX'); ?></p>');			jQuery('#errorModal').modal('show');
			return false;
		}

		if(frm.job.value == 0 ){
			frm.job.focus();			jQuery('#error_message').html('<p><?php echo JText::_('WRD_PROFILE_ALERT_PLEASE_SELECT_JOB'); ?></p>');			jQuery('#errorModal').modal('show');
			return false;
		}
		if(frm.job.value == 'other' && frm.o_job.value == ''){
			frm.job.focus();			jQuery('#error_message').html('<p><?php echo JText::_('WRD_PROFILE_ALERT_PLEASE_SELECT_JOB'); ?></p>');			jQuery('#errorModal').modal('show');
			return false;
		}
        if(frm.company_name.value == "")
		{
			jQuery('#error_message').html('<p><?php echo JText::_('WRD_PROFILE_ALERT_PLEASE_SUPPLY_YOUR_COMPANY_NAME'); ?></p>');			jQuery('#errorModal').modal('show');
			frm.company_name.focus();
			return false;
		}
	    return true;
	}
</script>
